This invention relates to a central processing unit (CPU) of a computer system, more particularly, to a method for saving or retrieving a set of CPU registers in procedure CALL or RETURN instructions.
In high performance computer systems, memory is allocated to each process or job by the operating system software. As each process is executed the CPU must assure, for system and process security reasons, that only the memory space allocated for that process is used. This assurance requires constant CPU checking of every memory address against the process memory boundaries, causing a slower process or job run time. To insure that the execution of some CPU instructions will complete successfully, it is often necessary to predict what memory space will be required before the operation is even started.
One such operation requiring this prediction is the pushing (writing) of register contents on a stack before a procedure is invoked. None of the registers can be written to the stack without first knowing that all can be written successfully. This requires determining the number of registers to be written, computing the boundary addresses, and comparing the addresses against the process memory allocation.
An example of this operation is a CALL macroinstruction, where one of the operations required in the execution of this instruction is to save (push/write to a memory stack) the contents of one or more of the general purpose registers as specified by the user in a save-mask found in memory. In one example, the VAX architecture requires that the memory required for the stack write be validated for the process before the writing is performed. According to the present invention, a method is described for quickly counting the bits in the save-mask, resulting in a count representing the number of registers that are to be saved. A subsequent microcode flow then uses the count value along with a base memory address to probe the boundaries of stack required, making sure that the needed memory is available in the stack. Thus, a method is provided which significantly reduces the execution steps and time required to pre-compute the memory boundary addresses for writing a variable number of registers to sequential memory locations.
In prior CPU implementations the problem was solved differently. Some used a method which first assumed the maximum number of bits to be set in the save-mask, and tried or probed memory with that assumption; then if a memory bounds failure occurred, the CPU reverted to counting the save-mask bits. Other prior CPU's started the operation by counting the save-mask bits. All of these previous CPU implementations utilized microcode procedures to count the number of bits in the save-mask. These procedures performed the operation by examining each of the save-mask bits, and accumulating a count representing the number of bits that were set. Since this procedure was always implemented with microcoded program loops, the operation took a significant number of cycles to complete, and caused a loss in performance. In contrast, the method of the present invention performs the same task using combinatorial logic, and produces the same result in one machine cycle.